﻿namespace Steamworks
{
    using System;
    using System.Diagnostics;
    using System.IO;
    using System.Runtime.InteropServices;
    using System.Text;

    public class DllCheck
    {
        private static bool CheckSteamAPIDLL()
        {
            string str;
            int num;
            if (IntPtr.Size == 4)
            {
                str = "steam_api.dll";
                num = 0x2d8c0;
            }
            else
            {
                str = "steam_api64.dll";
                num = 0x327a8;
            }
            IntPtr moduleHandle = GetModuleHandle(str);
            if (moduleHandle != IntPtr.Zero)
            {
                StringBuilder strFullPath = new StringBuilder(0x100);
                GetModuleFileName(moduleHandle, strFullPath, strFullPath.Capacity);
                string path = strFullPath.ToString();
                if (File.Exists(path))
                {
                    FileInfo info = new FileInfo(path);
                    if (info.Length != num)
                    {
                        return false;
                    }
                    if (FileVersionInfo.GetVersionInfo(path).FileVersion != "02.89.45.04")
                    {
                        return false;
                    }
                }
            }
            return true;
        }

        [DllImport("kernel32.dll", CharSet=CharSet.Auto)]
        private static extern int GetModuleFileName(IntPtr hModule, StringBuilder strFullPath, int nSize);
        [DllImport("kernel32.dll")]
        public static extern IntPtr GetModuleHandle(string lpModuleName);
        public static bool Test()
        {
            return true;
        }
    }
}

